package com.jyh.homework.homework2;

/**
 * @Author JYH
 * @Date 2024/8/7 16:40
 * @Description
 */
public class HomeWork2 {
    public static void main(String[] args) {
        work2 w1 = new work2();
        Thread t1 = new Thread(w1, "子线程");
        t1.start();

        for (int i = 1; i <= 5; i++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+"第"+i+"次执行");
        }


    }

}
class work2 implements Runnable{
    @Override
    public void run() {
        for (int i = 1; i <= 5; i++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+"第"+i+"次执行");
        }
    }
}